package com.szholly.plug.safe.entity.workday;

import java.util.HashMap;

import com.szholly.utils.cache.CacheFactory;
import com.szholly.utils.cache.data.IMedataCache;
import com.szholly.data.general.RowBase;

/**
 * 定义节假日与工作时间缓存处理类
 */
public class WorkDayHelper {

	/**
	 * 节假日缓存键
	 */
	static final String HolidaysCacheKey = "HolidaysCacheKey";

	/**
	 * 工作时间缓存键
	 */
	static final String WorkTimesCacheKey = "WorkTimesCacheKey";
	
	public static void clearCache(){
		IMedataCache medataCache = CacheFactory.getMedataCache();
		medataCache.Remove(HolidaysCacheKey);
		medataCache.Remove(WorkTimesCacheKey);
	}

	/**
	 * 获取节假日
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public static HashMap<String, RowBase> getHolidaysCache() {
		IMedataCache medataCache = CacheFactory.getMedataCache();
		if (!medataCache.HashKey(HolidaysCacheKey)) {
			return null;
		}
		return (HashMap<String, RowBase>) medataCache
				.Get(HolidaysCacheKey);
	}

	/**
	 * 设置节假日
	 * 
	 * @param value
	 */
	public static void setHolidaysCache(
			HashMap<String, RowBase> value) {
		IMedataCache medataCache = CacheFactory.getMedataCache();
		medataCache.Put(HolidaysCacheKey, value);
	}

	/**
	 * 获取工作时间
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public static HashMap<String, String> getWorkTimesCache() {
		IMedataCache medataCache = CacheFactory.getMedataCache();
		if (!medataCache.HashKey(WorkTimesCacheKey)) {
			return null;
		}
		return (HashMap<String, String>) medataCache
				.Get(WorkTimesCacheKey);
	}

	/**
	 * 设置工作时间
	 * 
	 * @param value
	 */
	public static void setWorkTimesCache(HashMap<String, String> value) {
		IMedataCache medataCache = CacheFactory.getMedataCache();
		medataCache.Put(WorkTimesCacheKey, value);
	}
}